package com.bluesky.plum.domain.northwind;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.bluesky.plum.domain.repository.Repository;
import com.bluesky.plum.domain.repository.search.condition.Condition;

public class EmployeeRepository extends HibernateDaoSupport implements
		Repository<Employee> {
	
	@Override
	public void add(
			 Employee entity) {

		getHibernateTemplate().save(entity);

	}

	@Override
	public List<Employee> find(Condition condition) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Employee> getAll() {
		return getHibernateTemplate().find("from Employee");
	}

	@Override
	public Employee getByIndex(final int index) {
		return getAll().get(index);
	}

	@Override
	public List<Employee> getByPage(int pageLength, int pageNumber) {
		// TODO
		return null;

	}

	@Override
	public int getCount() {
		return getAll().size();

	}

	
	@Override
	public void remove(Employee entity) {

		getHibernateTemplate().delete(entity);

	}

	
	@Override
	public void update(
			Employee oldEntity,
			Employee newEntity) {

		getHibernateTemplate().update(newEntity);
	}

	@Override
	public boolean equals(Employee obj1, Employee obj2) {
		return obj1.getId().equals(obj2.getId());

	}
}
